<template>
  <div>
      <!-- 语法一：
      口诀：让谁循环就放在谁身上
       -->
      <ul>
          <li v-for="( val, index) in arr" :key="index">
              {{val}} === {{index}}
          </li>
      </ul>
      <!--语法2： v-for="值变量名 in  目标结构" -->
      <ul>
          <li v-for="(obj, ind) in stuArr" :key="ind">
              <span>{{obj.id}}</span>
              <span>{{obj.name}}</span>
              <span>{{obj.sex}</span>
              <span>{{obj.hobby}}</span>
          </li>
      </ul>
      <!--语法3： v-for="(val,key) in 对象" 遍历数组-->
      <ul>
          <li v-for="(val,key) in tObj" >
              {{val}} === {{key}}
          </li>
      </ul>
      <!-- 语法4：遍历数字 -->
      <ul>
          <li v-for="n in count">{{n}}</li>
      </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: ["小明", "小欢欢", "大黄"],
      stuArr: [
        {
          id: 1001,
          name: "孙悟空",
          sex: "男",
          hobby: "吃桃子",
        },
        {
          id: 1002,
          name: "猪八戒",
          sex: "男",
          hobby: "背媳妇",
        },
      ],
      tObj: {
        name: "小黑",
        age: 18,
        class: "1期",
      },
      count: 10,
    };
  },
};
</script>